<template>
  <div>
    <el-card class="box-card">
      <h3>新建房屋</h3>
    </el-card>
    <el-card style="margin-top: 20px">
      <span>基础信息</span>
      <div>
        <el-form
          label-position="right"
          label-width="80px"
          :model="forms"
          style="width: 400px; margin-left: 200px; margin-top: 40px"
        >
          <el-form-item label="楼座">
            <!-- <el-input v-model="forms.howMany"></el-input> -->
            <el-select
              v-model="forms.buildingId"
              style="width: 100%"
              clearable
              placeholder="请选择楼座"
            >
              <el-option
                v-for="item in building"
                :key="item.buildingId"
                :label="item.howMany"
                :value="item.buildingId"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="房间号">
            <el-input v-model="forms.howPortal"></el-input>
          </el-form-item>
          <el-form-item label="房屋状态">
            <el-select v-model="forms.state" clearable    style="width: 100%" placeholder="请选择">
              <el-option label="自住" value="自住"></el-option>
              <el-option label="闲置" value="闲置"></el-option>
              <el-option label="出租" value="出租"></el-option>
              <el-option label="出借" value="出借"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="房屋用途">
            <el-select v-model="forms.houseUse" clearable    style="width: 100%" placeholder="请选择">
              <el-option label="普通住宅" value="普通住宅"></el-option>
              <el-option label="商业用地" value="商业用地"></el-option>
              <el-option label="商住两用" value="商住两用"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div style="margin-left: 350px">
          <el-button type="primary" @click="addPortal">提交</el-button>
          <el-button style="margin-left: 50px" type="primary">重置</el-button>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      forms: {
        buildingId:"",
        howMany: "",
        howPortal: "",
        houseUse: "",
        state: "",
        communityId:"",
      },
      building: [],
    };
  },
  created() {
    this.load();
  },
  methods: {
    addPortal() {
      this.forms.communityId=localStorage.getItem("communityId")
      console.log(this.forms);
      this.$axios
        .post("/housingestate/building/addPortalPc", this.forms)
        .then((res) => {
             this.$router.push({
           path:"/portal"
         })
        });
    },
    load() {
      this.$axios.post("/housingestate/building/loadPc?id="+localStorage.getItem("communityId")).then((res) => {
        console.log(res.data.data.data);
        this.building = res.data.data.data;
      });
    },
  },
};
</script>

<style scoped>
</style>